package com.qfedu.controller;

import com.qfedu.pojo.entity.GoodsSecondType;
import com.qfedu.pojo.req.GoodsSecondTypeReq;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.service.GoodsSecondTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName GoodsSecondTypeController
 * @Description TODO
 * @Author young
 * @Date 2022-09-27 14:28
 * @Version 1.0
 **/
@RestController
@RequestMapping("/goodsSecondType")
@Api(tags = "二级分类管理")
public class GoodsSecondTypeController {
    @Autowired
    GoodsSecondTypeService goodsSecondTypeService;

    @ApiOperation(value = "查询所有二级分类")
    @GetMapping("/findAll")
    public BaseResp findAll(){
        return goodsSecondTypeService.findAll();
    }

    @ApiOperation(value = "新增或修改二级分类")
    @PostMapping("/saveOrUpdate")
    public BaseResp saveOrUpdate(@RequestBody GoodsSecondTypeReq goodsSecondTypeReq){
        return goodsSecondTypeService.saveOrUpdate(goodsSecondTypeReq);
    }

    @ApiOperation(value = "根据id删除二级分类")
    @PostMapping("/deleteById")
    public BaseResp deleteById(@RequestBody GoodsSecondTypeReq goodsSecondTypeReq){
        return goodsSecondTypeService.deleteById(goodsSecondTypeReq);
    }

}
